package com.demo.springmvc底层演示.demo4;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

public class Controller {
	
	public ModelAndView test1() {
		ModelAndView mav = new ModelAndView("view1");
		mav.addObject("name", "张三");
		return mav;
	}
	
	public String test2() {
		return "view2";
	}
	
	@ModelAttribute
	public User test3() {
		return new User("李四", 20);
	}
	
	public User test4() {
		return new User("王五", 30);
	}
	
	public HttpEntity<User> test5() {
		return new HttpEntity<>(new User("赵六", 40));
	}
	
	public HttpHeaders test6() {
		HttpHeaders headers = new HttpHeaders();
		headers.add("Content-type", "text/html");
		return headers;
	}
	
	@ResponseBody
	public User test7() {
		return new User("钱七", 50);
	}

}
